package cn.edu.scau.cmi.yangzhengkai.composite.safe;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SafeComposite extends SafeComponent{

	private String name;
	private SafeComponent parent;
	
	private Set<SafeComponent> children = new HashSet<SafeComponent>();
	
	public SafeComposite(String name,SafeComponent parent) {

		this(name);
		this.parent = parent;
	}
	
	public SafeComposite(String name) {

		this.name = name;
	}
		
	
	public SafeComposite() {

	}
	
	@Override
	public String dosomething() {
		return "this is a Safe Composite";
	}
	
	
	@Override
	public SafeComponent getParent() {
		return parent;
	}
	
	
	public SafeComponent removeChild(SafeComponent child) {
		children.remove(child);
		return this;
	}
	
	
	public SafeComponent addChild(SafeComponent child) {
		children.add(child);
		return this;
	}
	

	public String getName() {
		return name;
	}

	
	public void setName(String name) {
		this.name = name;
	}

	
	public Set<SafeComponent> getChildren() {
		return children;
	}

	
	public void setChildren(Set<SafeComponent> children) {
		this.children = children;
	}
	
	@Override
	public String toString() {
		
		return this.name;
	}
	
}
